
import com.liuxingwu.mapper.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;
import java.io.InputStream;


/**
 * @author 扫地生_LiuXingWu
 */
public class Mytest {
    @Test
    public void test() throws IOException {
//        String resource = "mybatis-config.xml";
//        InputStream in = Resources.getResourceAsStream(resource);
//        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(in);
//        SqlSession sqlSession = sessionFactory.openSession(true);
//
//        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
//        mapper.queryUser();
//        sqlSession.close();

        ApplicationContext context = new ClassPathXmlApplicationContext("spring-dao.xml");
        UserMapper userMapperImpl = context.getBean("userMapperImpl2", UserMapper.class);
        userMapperImpl.queryUser();
    }
}
